<template>
  <div class="app-container clue-myclue">
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column label="序号" type="index"> </el-table-column>
      <el-table-column prop="id" label="线索号"></el-table-column>
      <el-table-column prop="clueName" label="线索名称"></el-table-column>
      <el-table-column prop="userName" label="征集人"></el-table-column>
      <el-table-column prop="relativePhone" label="联系电话"></el-table-column>
      <el-table-column prop="price" label="报价"></el-table-column>
      <el-table-column prop="status" label="审核情况"></el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button
            type="primary"
            plain
            size="small"
            icon="el-icon-s-operation"
            @click="showDetailDialog(scope.row)"
          >
            查看详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-warp">
      <el-pagination
        :current-page="current"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      >
      </el-pagination>
    </div>

    <MyclueDetail></MyclueDetail>
  </div>
</template>

<script>
import { getAllMyClue } from '@/api/clue/myclue';
import MyclueDetail from './components/myclue-detail';
export default {
  components: {
    MyclueDetail
  },
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      current: 1, // 当前页
      limit: 10, // 一页几个
      total: 0 // 总数
    };
  },
  created() {
    this.getAllMyClue();
  },
  methods: {
    /**
     * 线索详情对话框
     */
    showDetailDialog() {
      this.dialogVisible = true;
    },
    /**
     * 处理分页修改
     */
    handleSizeChange(val) {
      this.limit = val;
      this.getAllMyClue();
    },
    handleCurrentChange(val) {
      this.current = val;
      this.getAllMyClue();
    },
    /**
     * 获取我的线索提交记录
     */
    async getAllMyClue() {
      const { data: res } = await getAllMyClue();
      console.log('api=我的线索提交记录', res);
      this.tableData = res.data.clues;
    }
  }
};
</script>

<style lang="scss" scoped>
.clue-myclue {
  .pagination-warp {
    margin-top: 20px;
    position: relative;
    .el-pagination {
      position: absolute;
      right: 0;
      top: 0;
    }
  }
}
</style>
